<template>
    <h3>注册</h3>
    <table border="1">
        <tr>
            <td>账号</td>
            <td>
                <input type="text" v-model="info.UName"/>
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="password" v-model="info.Upwd"/>
            </td>
        </tr>

        <tr>
            <td colspan="2">
                <input type="button" value="注册" @click="RegistInfo">
            </td>
           
        </tr>
    </table>
</template>


<script setup lang="ts">
import {ref} from 'vue'
import axios from 'axios';

const info=ref({
    UName:"",
    Upwd:""
})

const RegistInfo=()=>{
    axios.post("http://localhost:2134/api/User/Regist",{

        UName:info.value.UName,
        Upwd:info.value.Upwd
    })
    .then((res)=>{
        console.log(res.data)
        if(res.data>0){
            alert("注册成功")
            location.href="/Login"
        }
        else if(res.data==-1){
            alert("用户账号不能重复")
        }
        else{
            alert("用户账号不能重复")
        }
    })
}

</script>

